# Locate ZLIB-c
# This module defines
# ZLIB_LIBRARY
# ZLIB_FOUND, if false, do not try to link to ZLIB-c 
# ZLIB_INCLUDE_DIR, where to find the headers
#
# $ZLIB_DIR is an environment variable that would

FIND_PATH(ZLIB_INCLUDE_DIR zlib.h 
    HINTS
       ${ZLIB_DIR}
       $ENV{ZLIB_DIR}
       $ENV{ZLIB_DIR}
       ${DELTA3D_EXT_DIR}
       ${DELTA3D_ROOT}
       $ENV{DELTA_ROOT}/ext
       $ENV{DELTA_ROOT}
       $ENV{OSG_ROOT}
    PATH_SUFFIXES
       inc include
)
MARK_AS_ADVANCED(ZLIB_INCLUDE_DIR)

MACRO(FIND_ZLIB_LIBRARY MYLIBRARY MYLIBRARYNAME)

FIND_LIBRARY(${MYLIBRARY}
    NAMES ${MYLIBRARYNAME} 
    HINTS
       ${ZLIB_DIR}
       $ENV{ZLIB_DIR}
       $ENV{ZLIB_DIR}
       ${DELTA3D_EXT_DIR}
       $ENV{DELTA_ROOT}/ext
       $ENV{DELTA_ROOT}
       $ENV{OSG_ROOT}
    PATH_SUFFIXES
       lib lib64 Frameworks
)
MARK_AS_ADVANCED(${MYLIBRARY})
ENDMACRO(FIND_ZLIB_LIBRARY MYLIBRARY MYLIBRARYNAME)

SET(ZLIB_LIST zlib1 )
FIND_ZLIB_LIBRARY(ZLIB_LIBRARY "${ZLIB_LIST}")
SET(ZLIB_DEBUG_LIST zlib1d)
FIND_ZLIB_LIBRARY(ZLIB_LIBRARY_DEBUG "${ZLIB_DEBUG_LIST}")

SET(ZLIB_FOUND "NO")
IF(ZLIB_LIBRARY AND ZLIB_INCLUDE_DIR)
    SET(ZLIB_FOUND "YES")
ENDIF(ZLIB_LIBRARY AND ZLIB_INCLUDE_DIR)


